package cn.woflcode.game.model.util;

import cn.woflcode.game.model.*;

import java.awt.*;
import java.util.List;

/**
 * 碰撞判断工具类
 * 该类中,应该存放飞行物判断的方法
 */
public class HitUtil {
    //
    public static boolean heroPlaneVSLife(HeroPlane heroPlane, Life life) {
        //竖线长度a
        int a = heroPlane.getCenterY() - life.getCenterY();
        //横线长度b
        int b = heroPlane.getCenterX() - life.getCenterX();
        //斜线长度c
        double c = Math.sqrt(a * a + b * b);
        return c < heroPlane.getR() + life.getR();
    }
    //英雄战机和小敌机的碰撞判断
    public static boolean heroPlaneVSEnemyPlane(HeroPlane heroPlane, SmallEnemyPlane enemyPlane) {
        //竖线长度a
        int a = heroPlane.getCenterY() - enemyPlane.getCenterY();
        //横线长度b
        int b = heroPlane.getCenterX() - enemyPlane.getCenterX();
        //斜线长度c
        double c = Math.sqrt(a * a + b * b);
        return c < heroPlane.getR() + enemyPlane.getR();
    }
    //英雄战机和大敌机的碰撞判断
    public static boolean heroPlaneVSBigEnemyPlane(HeroPlane heroPlane, BigEnemyPlane bigenemyPlane) {
        //竖线长度a
        int a = heroPlane.getCenterY() - bigenemyPlane.getCenterY();
        //横线长度b
        int b = heroPlane.getCenterX() - bigenemyPlane.getCenterX();
        //斜线长度c
        double c = Math.sqrt(a * a + b * b);
        return c < heroPlane.getR() + bigenemyPlane.getR();
    }

    //英雄战机和小敌机子弹的碰撞判断
    public static boolean heroPlaneVSEnemyBullet(HeroPlane heroPlane, EnemyBullet enemyBullet) {
        //竖线长度a
        int a = heroPlane.getCenterY() - enemyBullet.getCenterY();
        //横线长度b
        int b = heroPlane.getCenterX() - enemyBullet.getCenterX();
        //斜线长度c
        double c = Math.sqrt(a * a + b * b);
        return c < heroPlane.getR() + enemyBullet.getR();
    }
           //英雄战机和大敌机子弹的碰撞判断
        public static boolean cc(HeroPlane heroPlane, BigEnemyBullet bigenemyBullet) {
            //竖线长度a
            int a = heroPlane.getCenterY() - bigenemyBullet.getCenterY();
            //横线长度b
            int b = heroPlane.getCenterX() - bigenemyBullet.getCenterX();
            //斜线长度c
            double c = Math.sqrt(a * a + b * b);
            return c < heroPlane.getR() + bigenemyBullet.getR();
        }

            //英雄子弹和小敌机
    public static boolean heroBulletVSEnemyPlane(HeroBullet heroBullet, SmallEnemyPlane enemyPlane) {
        //竖线长度a
        int a = heroBullet.getCenterY() - enemyPlane.getCenterY();
        //横线长度b
        int b = heroBullet.getCenterX() - enemyPlane.getCenterX();
        //斜线长度c
        double c = Math.sqrt(a * a + b * b);
        return c < heroBullet.getR() + enemyPlane.getR();
    }
    public static boolean aa(HeroBullet heroBullet,BigEnemyPlane bigEnemyPlane){
        //竖线长度a
        int a = heroBullet.getCenterY() - bigEnemyPlane.getCenterY();
        //横线长度b
        int b = heroBullet.getCenterX() - bigEnemyPlane.getCenterX();
        //斜线长度c
        double c = Math.sqrt(a * a + b * b);
        return c < heroBullet.getR() + bigEnemyPlane.getR();
    }

    //英雄子弹和敌机子弹
    public static boolean heroBulletVSEnemyBullet(HeroBullet heroBullet, EnemyBullet enemyBullet) {
        //竖线长度a
        int a = heroBullet.getCenterY() - enemyBullet.getCenterY();
        //横线长度b
        int b = heroBullet.getCenterX() - enemyBullet.getCenterX();
        //斜线长度c
        double c = Math.sqrt(a * a + b * b);
        return c < heroBullet.getR() + enemyBullet.getR();
    }
    //英雄子弹和大敌机子弹
    public static boolean hearBulletVSBigEnemyBullet(HeroBullet heroBullet, BigEnemyBullet bigenemyBullet) {
        //竖线长度a
        int a = heroBullet.getCenterY() - bigenemyBullet.getCenterY();
        //横线长度b
        int b = heroBullet.getCenterX() - bigenemyBullet.getCenterX();
        //斜线长度c
        double c = Math.sqrt(a * a + b * b);
        return c < heroBullet.getR() + bigenemyBullet.getR();
    }
}
